package com.freecloud.javabasics.design.observer;

import java.lang.reflect.Method;

/**
 * @Author: maomao
 * @Date: 2019-11-19 09:22
 */
public class Event {
    /**
     * 事件源
     */
    private Object source;
    /**
     * 目标
     */
    private Object target;
    /**
     * 回调
     */
    private Method callback;
    /**
     * 触发
     */
    private String trigger;
    /**
     * 时间
     */
    private long time;

    public Event(Object target, Method callback) {
        this.target = target;
        this.callback = callback;
    }

    void setSource(Object source) {
        this.source = source;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public Object getSource() {
        return source;
    }

    public Object getTarget() {
        return target;
    }

    public void setTarget(Object target) {
        this.target = target;
    }

    public Method getCallback() {
        return callback;
    }

    public void setCallback(Method callback) {
        this.callback = callback;
    }

    public String getTrigger() {
        return trigger;
    }

    public void setTrigger(String trigger) {
        this.trigger = trigger;
    }

    @Override
    public String toString() {
        return "Event{" +
                "\r\nsource=" + source +
                ",\r\n target=" + target +
                ",\r\n callback=" + callback +
                ",\r\n trigger='" + trigger + '\'' +
                ",\r\n time=" + time +
                "\r\n}";
    }
}
